-
Notifications
You must be signed in to change notification settings - Fork 512
METRON-1283: Install Elasticsearch template as a part of the mpack startup scripts #817
Conversation
The templates are installed from ansible right now for the vagrant builds. Wouldn't we need to remove that step? Have you tested full_dev ? |
Hi @anandsubbu - Just a few issues that came to mind. These may or may not be problems, so I just wanted to open them for discussion.
|
Hi @ottobackwards , made the change to remove the ES template installation from 'load_web_template' role for vagrant deployments. Fired up full-dev with the change and it comes up fine. Was able to launch and view alerts in the UI. Hi @nickwallen - sure, what you are saying makes sense to me. To address point 1, I have moved the ES template installation step into the Indexing "Install" method, so this would be called only once. This would also not meddle with users making customization to the templates subsequently. Point 2 is partly addressed with the recent commit in that it takes care of ES service not running scenario. However I am not sure about how we need to proceed with a user not using Elasticsearch at all. If I have understand right, this is something that would require changes and considerations to packaging and installation, not limited to this pull request alone. Please correct me if I am missing something. |
Restarting travis |
Did this work for you? I would think that when the Indexing Install/Configure method runs, Elasticsearch is most likely not running. |
You're right @nickwallen , it wouldn't work. I reworked on the patch and here are the latest changes:
I ran the following test scenarios to validate the changes: Full dev deployment
12-node deployment
|
If the indexing start doesn't install the templates because ES is down or something, will they be installed if restarted and ES is available, or is it one shot, pass or fail. |
If the install fails the first time due to ES being down, then we WARN and move on. If ES service comes up later, the admin needs to install the templates subsequently by using 'Ambari -> Metron -> Service Actions -> Elasticsearch Template Install' option. Alternatively s/he can also stop the Indexing service and start again so the template will be installed (Note that calling "restart" on the Indexing service will not trigger the template installation) |
How are we going to document all this? |
try: | ||
if not commands.is_elasticsearch_template_installed(): | ||
self.elasticsearch_template_install(env) | ||
commands.set_elasticsearch_template_installed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anandsubbu said...
If the install fails the first time due to ES being down, then we WARN and move on. If ES service comes up later, the admin needs to install the templates subsequently by using 'Ambari -> Metron -> Service Actions -> Elasticsearch Template Install' option
I am reading the code differently. If we attempt to install the templates, but it fails because ES is down, then an exception is thrown and we never set the flag file. This is good because the next time we start indexing, it will again attempt to install the index templates. It will continue to attempt the index template install until that flag file is set. Only if the templates actually get installed will the flag file get set, which causes it to stop attempting the install. This is exactly what we want.
The only thing I would suggest is that we attempt the template install BEFORE starting the indexing topology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @nickwallen . Sure, done!
+1 Thanks for fixing this @anandsubbu! This takes out a manual step that if missed can cause some ugly, unexpected problems. This is contingent on getting @ottobackwards buy-in before merging too. |
Hi @ottobackwards , let me know what you think. |
I think we need to document this somewhere. I am not sure where though. |
I have added this to the Elasticsearch README in my recent commit. Please see here: The preceding section to the template installation talks about the update required to the templates. I hence found this to be a better option than hosting it in the Metron Indexing README. |
## Installing Elasticsearch Templates | ||
|
||
The stock set of Elasticsearch templates for bro, snort, yaf, error index and meta index are installed automatically during the first time install and startup of Metron Indexing service. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of saying 'in the rare case', it might be better to say:
"It is possible that Elasticsearch is not available when the Metron Indexing Service starts the Elasticsearch topology, in that case the Elasticsearch templates will not be installed."
Also, this doesn't document the scenarios you have been describing fully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworded per your suggestion.
I believe the README section covers the current behavior with my change. If you are talking about the scenarios noted in the PR description, then these are captured in the existing ES README under the section Using Metron with Elasticsearch 2.x. Please let me know which specific scenario you are referring to and I would be happy to include them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My impression from these comments is that automatic installation could still possibly happen. That is what I'm referring to as being missing. I may be confused though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, this comment and review is the same scenario described in the README as:
It is possible that Elasticsearch service is not available when the Metron Indexing Service startup, in that case the Elasticsearch template will not be installed. For such a scenario, an Admin can install the template manually from the Ambari UI by following the below flow:
Ambari UI -> Services -> Metron -> Service Actions -> Elasticsearch Template Install
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I am def. confused. I don't see how "It will try again next time X happens" as the same as Go and do it manually in ambari
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let me try to explain more using examples:
Scenario 1 - Happy Path
- Fresh install
- ES service up and running
- When the Indexing service comes up, it also installs the ES templates
- Admin can start ingesting into sensors, launch alerts UI and everything works
Scenario 2 - ES service down
- Fresh install
- For some reason, the ES service is down when the Indexing service is coming up
- We log a warning message in the Ambari install logs, and the Indexing service starts up fine.
- Once the ES service issue is resolved, the Admin needs to install the ES templates manually before s/he can start ingesting into sensors. This can be done in two ways:
- Using the Ambari UI -> Services -> Metron -> Service Actions -> Elasticsearch Template Install
- By stopping the Metron Indexing service from Ambari UI, and starting it again so that it can trigger the piece of code to install the template.
Now, from a documentation perspective, point 2 above is counter intuitive IMHO, since it would not make sense to ask the Admin to stop/start Indexing service in order to have the ES template installed. I have hence documented only the first option--which is also the same way it is done presently.
Let me know if this helps clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, if that is the way it works, and is what will happen, you should documented it. If it doesn't make sense enough to document, then change the behavior.
We have people all over the user's list with issues understanding what is going on with things.
"Oh, the doc doesn't say it but we do try to install automatically next time or if you .... " isn't right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, added both methods in the latest doc change.
Ambari UI -> Services -> Metron -> Service Actions -> Elasticsearch Template Install | ||
|
||
_Method 2_ - Stop the Metron Indexing service, and start it again from Ambari UI. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not trying to nit, but this should expressly call out that we will attempt to install the templates each START until successful.
Method 2 - Stop the Metron Indexing service, and start it again from Ambari UI.
Note: The Metron Indexing service tracks if it has successfully installed the Elasticsearch templates, and will attempt to do so each time it is Started until successful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, added this as well @ottobackwards
+1, thanks! |
…rtup scripts (anandsubbu via nickwallen) closes apache#817
Contributor Comments
For a Metron multi-node deployment using mpack, the Elasticsearch template is required to be installed manually post-setup. These templates are required for the proper working of, for e.g. the Alerts UI.
In the event that these templates are not installed, and if data is ingested, these would not be shown in the Alerts UI, since there would be missing fields without the template files (E.g. snort alert indices are not displayed in the Alerts UI, since it is missing the "alerts" field from the mapping). In such a case, one needs to install the templates, delete all indices for the given parser and re-ingest data again into the parser for it to appear in the Alerts UI.
Further, the indices from all the parsers will have to be deleted and re-ingested again which could be a tedious job in the event that this step was missed out by chance. I have also seen other ill-effects from having stale indices for parsers that was created before template install.
While documenting the template installation is a good practice, nothing would more failsafe than installing the template as a part of the mpack startup scripts itself.
I have added the ES template install step just before starting the Indexing topology, since I found this to be the closest related step when this could be done. Do let me know if this needs to be moved to a different point in the startup, and I can make the change.
Testing Done
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html
:Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.